package com.yourvote.user.action;

import com.opensymphony.xwork2.ActionSupport;
import com.yourvote.model.User;
import org.displaytag.pagination.PaginatedList;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by IntelliJ IDEA.
 * User: pavlo.fedyna
 * Date: 9/3/12
 * Time: 12:10 PM
 * To change this template use File | Settings | File Templates.
 */
public class WelcomeUserAction extends ActionSupport{
    private String username;
    private String password;
    private List<User> userList = new ArrayList<User>();
    private List<String> userNames = new ArrayList<String>();
    private PaginatedList users;
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String execute() {
        Random random = new Random();
        User user = new User();
        user.setId(random.nextLong());
        user.setFirstName(username);
        user.setPassword(password);
        user.setLastName(username);
//        Dao.INSTANCE.add(user);
//        userList = Dao.INSTANCE.listUsers();
//        for (User user1 : userList) {
//            userNames.add(user1.getFirstName());
//        }

        return SUCCESS;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<String> getUserNames() {
        return userNames;
    }

    public void setUserNames(List<String> userNames) {
        this.userNames = userNames;
    }

    public PaginatedList getUsers() {
        return users;
    }

    public void setUsers(PaginatedList users) {
        this.users = users;
    }
}
